<?php

use Illuminate\Routing\Router;
use Illuminate\Support\Facades\Route;
use Dcat\Admin\Admin;
use App\Admin\Controllers\NewsController;
use App\Admin\Controllers\HomePageController;
use App\Admin\Controllers\MenusController;
use App\Admin\Controllers\ProductsController;
use App\Http\Controllers\Admin\EditorUploadController;


Admin::routes();

Route::group([
    'prefix'        => config('admin.route.prefix'),
    'namespace'     => config('admin.route.namespace'),
    'middleware'    => config('admin.route.middleware'),
], function (Router $router) {

//    $router->get('/', 'HomePageController@index');
//    $router->get('/news', 'NewsController@index');
    $router->resource('news', 'NewsController');
    $router->resource('product', 'ProductsController');
    $router->resource('menu', 'MenusController');
    $router->resource('home', 'HomePageController');
    $router->post('api/upload/image', 'UploadController@handle');
    $router->post('editor/upload', [EditorUploadController::class, 'upload']);


    $router->post('home/submit', [HomePageController::class, 'submit'])->name('admin.home.submit');
    $router->post('home/approve', [HomePageController::class, 'approve'])->name('admin.home.approve');
    $router->post('home/reject', [HomePageController::class, 'reject'])->name('admin.home.reject');

    $router->post('news/submit', [NewsController::class, 'submit'])->name('admin.news.submit');
    $router->post('news/approve', [NewsController::class, 'approve'])->name('admin.news.approve');
    $router->post('news/reject', [NewsController::class, 'reject'])->name('admin.news.reject');

    $router->post('product/submit', [ProductsController::class, 'submit'])->name('admin.product.submit');
    $router->post('product/approve', [ProductsController::class, 'approve'])->name('admin.product.approve');
    $router->post('product/reject', [ProductsController::class, 'reject'])->name('admin.product.reject');

    $router->post('menu/submit', [MenusController::class, 'submit'])->name('admin.menu.submit');
    $router->post('menu/approve', [MenusController::class, 'approve'])->name('admin.menu.approve');
    $router->post('menu/reject', [MenusController::class, 'reject'])->name('admin.menu.reject');

});
